package com.ck.daoImpl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.ck.dao.TiankongDAO;
import com.ck.domain.Tiankong;
import com.ck.domain.Xuanze;

public class TiankongDAOImpl extends SqlMapClientDaoSupport implements
		TiankongDAO {

	public List<Tiankong> getAllTiankong() {
		return (List<Tiankong>)getSqlMapClientTemplate().queryForList("getAllTiankong");
	}
	
	public Tiankong getTiankongById(Integer id) {
		return (Tiankong) getSqlMapClientTemplate().queryForObject("getTiankongById",id);
	}

	public List<Tiankong> getTiankongForExercise(Tiankong tiankong){
		return (List<Tiankong>) getSqlMapClientTemplate().queryForList("getTiankongForExercise",tiankong);
	}
	
	public List<Tiankong> getTiankongForPaper(Integer difficulty, Integer score,
			Integer chapter) {
		Tiankong tiankong = new Tiankong();
		tiankong.setDifficulty(difficulty);
		tiankong.setScore(score);
		tiankong.setChapter(chapter);
		
		return (List<Tiankong>) getSqlMapClientTemplate().queryForList("getTiankongForPaper",tiankong);
	}
	
	public List<Tiankong> getTiankongByChapter(Integer chapter) {
		return (List<Tiankong>) getSqlMapClientTemplate().queryForList("getTiankongByChapter",chapter);
	}

	public void addNewTiankong(Tiankong tiankong) {
		getSqlMapClientTemplate().insert("addNewTiankong", tiankong);
	}

	public void updateTiankongInfo(Tiankong tiankong) {
		getSqlMapClientTemplate().update("updateTiankongInfo", tiankong);
	}

	public void removeTiankongImage(Tiankong tiankong) {
		getSqlMapClientTemplate().update("removeTiankongImage", tiankong);
	}

}
